<template>
  <div class="home">
    <div class="home-text"></div>
  </div>
</template>

<script setup>
import useApp from '@/store/app'
import { ElMessage } from 'element-plus'

const route = useRoute()
const router = useRouter()
const appStore = useApp()

// TODO 需要和 Login 界面的登录做合并
function goLogin() {
  appStore
    .login(JSON.parse(localStorage.getItem('login-info')))
    .then(() => {
      router.push('/chat')
    })
    .catch(() => {
      ElMessage.error('登录失败')
      router.push('/login')
    })
}

setTimeout(() => {
  if (appStore.automaticLogon) {
    goLogin()
  } else {
    router.push(route.query.to)
  }
}, 1500)
</script>

<style lang="scss" scoped>
.home {
  @include use-flex(center, center);
  position: absolute;
  height: 768px;
  width: 1240px;
  background-image: url('@/assets/image/public-view/start-page-bg.jpg');
  background-size: 100% 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: var(--elp-border-radius-16);
  background-repeat: no-repeat;
  box-shadow: var(--elp-box-shadow);
  .home-text {
    height: 640px;
    width: 300px;
    background-image: url('@/assets/image/public-view/start-page-text.gif');
    background-size: 100% 100%;
  }
}
</style>
